package by.dkusch.aircompany.webapp.page.users.panel;

import java.util.Arrays;

import org.apache.wicket.bean.validation.PropertyValidator;
import org.apache.wicket.markup.html.form.CheckBox;
import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.EnumChoiceRenderer;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.ResourceModel;

import by.dkusch.aircompany.model.tables.UserGrant;
import by.dkusch.aircompany.model.tables.enums.FormType;

public class GrantRowPanel extends Panel {

	private static final long serialVersionUID = 1L;

	public GrantRowPanel(String id, final UserGrant grant) {
		super(id);

		final CheckBox chBEdit = new CheckBox("editFl");
		chBEdit.add(new PropertyValidator<Boolean>()).setLabel(new ResourceModel("user.grant.list.editfl"));
		add(chBEdit);

		final CheckBox chBView = new CheckBox("viewFl");
		chBView.add(new PropertyValidator<Boolean>()).setLabel(new ResourceModel("user.grant.list.viewfl"));
		add(chBView);

		final CheckBox chBDel = new CheckBox("deleteFl");
		chBDel.add(new PropertyValidator<Boolean>()).setLabel(new ResourceModel("user.grant.list.delfl"));
		add(chBDel);

		final TextField<String> tfCode = new TextField<String>("code");
		tfCode.add(new PropertyValidator<String>()).setLabel(new ResourceModel("user.grant.list.code")).setEnabled(false);
		add(tfCode);

		final DropDownChoice<FormType> chForm = new DropDownChoice<FormType>("formId", Arrays.asList(FormType.values()), new EnumChoiceRenderer<FormType>(this));
		chForm.add(new PropertyValidator<FormType>()).setLabel(new ResourceModel("user.grant.list.form")).setEnabled(false);
		add(chForm);
	}


}
